package com.java.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;

public class ServerOutputThread extends Thread {

	private Socket socket;

	public ServerOutputThread(Socket socket) {
		this.socket = socket;
	}

	@Override
	public void run() {
		OutputStream out = null;
		try {
			out = socket.getOutputStream();
			//out.write("如果上天知我心诚，就让石头也发芽吧。".getBytes());
			while (true){
				BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
				String line = reader.readLine();
				out.write(line.getBytes());
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
